﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Warehouse.ErrorCode;
using Warehouse.Api.Write.AllCation.Command.Checksheet;
using Microsoft.AspNetCore.Authorization;

namespace Warehouse.Api.Write.Controllers
{
    /// <summary>
    /// 盘点单控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ChecksheetController : ControllerBase
    {
        public readonly IMediator mediator;

        public ChecksheetController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加盘点信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        [Authorize]
        public Task<ApiResult<int>> AddChecksheet(AddChecksheetCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除盘点信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        [Authorize]
        public Task<ApiResult<int>> DeleteChecksheet(DeleteChecksheetCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 盘点单更新的方法
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPut]
        [Authorize]
        public Task<ApiResult<int>> UpadetChecksheet(UpdaetChecksheetCommand request)
        {
            return mediator.Send(request);
        }
    }
}
